<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="org.internna.iwebmvc.crypto.Cipherer" %>
<%@ page import="org.internna.iwebmvc.model.ui.Filter" %>
<%@ page import="org.internna.iwebjtracker.model.TrackerUser" %>
<%@ page import="org.internna.iwebmvc.security.UserManager" %>
<%@ page import="org.internna.iwebmvc.spring.jee.IWebMvcCombinedFilter" %>
<%@ page import="org.internna.iwebjtracker.spring.mvc.IWebJTrackerModelDecoratorInterceptor" %>
<%@ taglib prefix="iwebmvc" uri="http://tags.iwebmvc.com" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<c-rt:set var="sessionUser" value="<%= UserManager.SESSION_USER %>" />
<c-rt:set var="activityClass" value="<%= org.internna.iwebjtracker.model.Activity.class %>" />
<c-rt:set var="projectClass" value="<%= org.internna.iwebjtracker.model.DefaultProject.class %>" />
<c-rt:set var="activityOrder" value='<%= new org.internna.iwebmvc.model.ui.Sort("eventDate", true) %>' />
<%
    List filters = new ArrayList();
    Cipherer cipherer = (Cipherer) request.getAttribute(Cipherer.CIPHERER);
    TrackerUser trackerUser = (TrackerUser) request.getAttribute(IWebJTrackerModelDecoratorInterceptor.TRACKER_USER);
    Filter collection = new Filter();
    collection.setType("COLLECTION");
    collection.setPath("observers");
    collection.setFrom(cipherer.encrypt(trackerUser.getId().toString()));
    collection.setEntityClass(cipherer.encrypt(TrackerUser.class.getName()));
    collection.setRange(false);
    filters.add(collection);
    pageContext.setAttribute("filters", filters);
    List activityFilters = new ArrayList();
    Filter activityCollection = new Filter();
    activityCollection.setType("COLLECTION");
    activityCollection.setPath("project.observers");
    activityCollection.setFrom(cipherer.encrypt(trackerUser.getId().toString()));
    activityCollection.setEntityClass(cipherer.encrypt(TrackerUser.class.getName()));
    activityCollection.setRange(false);
    activityFilters.add(activityCollection);
    pageContext.setAttribute("activityFilters", activityFilters);
%>
<iwebmvc:panel title="ui.myprojects.projects" width="99%;margin:0">
    <iwebmvc:filteredgrid id="myProjects" entityClass="${projectClass}" currentDepthLevel="0" baseColumnWidth="100" pages="5" rows="8" selectionMode="single" filters="${filters}">
        <div class="overclear" style="vertical-align:top">
            <div class="float_left" style="padding-top:5px;margin-left:15px">
                <iwebmvc:sprite id="myProjectsFilter" text="iwebmvc.ui.crud.filter;${projectClass.name}" sprite="table_${sessionScope[sessionUser].theme}.png" top="-250px" position="after">
                    showprojectActivityFilter("my", true, true);
                </iwebmvc:sprite>
                <iwebmvc:sprite id="myProjectsHide" text="iwebmvc.ui.crud.hide;${projectClass.name}" sprite="table_${sessionScope[sessionUser].theme}.png" top="-300px" style="display:none" position="after">
                    showprojectActivityFilter("my", true, false);
                </iwebmvc:sprite>
            </div>
            <div class="float_right" style="padding-top:6px;padding-right:15px">
                <iwebmvc:sprite id="openMyProject" text="ui.project.open" sprite="table_${sessionScope[sessionUser].theme}.png" top="-150px" position="before" style="opacity:0.4">
                    var selection = dijit.byId("gridmyProjects").selection;
                    if ((selection.selectedIndex >= 0) && (selection.getSelected()[0] != null)) openProjectTab(selection);
                </iwebmvc:sprite>
            </div>
        </div>
    </iwebmvc:filteredgrid>
</iwebmvc:panel>
<div class="panelSeparator"></div>
<iwebmvc:panel title="ui.myprojects.activities" width="99%;margin:0">
    <iwebmvc:filteredgrid id="myActivities" entityClass="${activityClass}" currentDepthLevel="0" baseColumnWidth="100" pages="5" rows="12" selectionMode="none" defaultSort="${activityOrder}" filters="${activityFilters}" hideFiltersOnLoad="true">
        <div class="overclear" style="vertical-align:top">
            <div class="float_left" style="padding-top:5px;margin-left:15px">
                <iwebmvc:sprite id="myActivitiesFilter" text="iwebmvc.ui.crud.filter;${activityClass.name}" sprite="table_${sessionScope[sessionUser].theme}.png" top="-250px" position="after">
                    showprojectActivityFilter("my", false, true);
                </iwebmvc:sprite>
                <iwebmvc:sprite id="myActivitiesHide" text="iwebmvc.ui.crud.hide;${activityClass.name}" sprite="table_${sessionScope[sessionUser].theme}.png" top="-300px" style="display:none" position="after">
                    showprojectActivityFilter("my", false, false);
                </iwebmvc:sprite>
            </div>
        </div>
    </iwebmvc:filteredgrid>
</iwebmvc:panel>
<script type="text/javascript">
    dojo.addOnLoad(myProjectsOnLoad);
</script>